<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns:u="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:t="http://com.ss.stockmanager/jsf"
	xmlns:p="http://primefaces.org/ui" xmlns="http://www.w3.org/1999/xhtml">

<body>
	<u:composition template="/pages/layout/pageLayout.xhtml">
		<u:define name="body">
			<h:form id="form">
				<p:panel id="panelFiltro" header="#{msgs.common_filtros}"
					rendered="#{!clienteController.addEdit}">
					<h:panelGrid columns="5">
						<h:outputText value="#{msgs.admCliente_nombre}" />
						<p:inputText value="#{clienteController.query.nombre}"
							maxlength="200" size="50" />
						<h:outputText value="#{msgs.admCliente_nombreFantasia}" />
						<p:inputText value="#{clienteController.query.nombreFantasia}"
							maxlength="200" size="50" />

						<p:commandButton value="Consultar"
							actionListener="#{clienteController.query}" update="dataTable">
						</p:commandButton>
					</h:panelGrid>
				</p:panel>

				<h:outputText value="&#160;" />

				<p:growl id="messages" life="5000" />
				<p:dataTable id="dataTable" var="cliente"
					value="#{clienteController.lazyDM}" paginator="true" rows="10"
					paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="10,15,20"
					rendered="#{!clienteController.addEdit}"
					emptyMessage="No se encontraron registros" dynamic="true"
					lazy="true">

					<f:facet name="header">
						<h:outputText value="#{msgs.admCliente_title}" />
					</f:facet>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{msgs.admCliente_nombre}" />
						</f:facet>
						<h:outputText value="#{cliente.nombre}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{msgs.admCliente_nombreFantasia}" />
						</f:facet>
						<h:outputText value="#{cliente.nombreFantasia}" />
					</p:column>

					<p:column style="width:80px">
						<f:facet name="header">
							<h:outputText value="#{msgs.common_opciones}" />
						</f:facet>
						<h:panelGrid columns="3">
							<p:commandLink actionListener="#{clienteController.edit}"
								update=":form">
								<h:graphicImage url="/resources/images/edit.gif"
									title="Modificar" style="border:0px" />
							</p:commandLink>
							<h:commandLink actionListener="#{clienteController.delete}"
								onclick="return confirm('¿Está seguro de eliminar el registro?');">
								<h:graphicImage url="/resources/images/delete.gif"
									title="Eliminar" style="border:0px" />
							</h:commandLink>
						</h:panelGrid>
					</p:column>

					<f:facet name="footer">
						<p:commandButton value="#{msgs.common_agregar}"
							actionListener="#{clienteController.add}" update=":form" />
					</f:facet>
				</p:dataTable>


				<h:panelGrid id="panel" columns="1"
					rendered="#{clienteController.addEdit}">

					<p:tabView id="tabView" widgetVar="tabView">
						<p:tab title="#{msgs.admCliente_datosPrincipales}">
							<p:focus for="nombreIT" />
							<p:panel header="#{msgs.admCliente_datosPrincipales}">
								<h:panelGrid columns="3">
									<h:outputText value="#{msgs.admCliente_nombre}" />
									<p:inputText id="nombreIT"
										value="#{clienteController.view.nombre}" maxlength="200"
										size="50">
										<f:validateBean for="nombreIT" />
									</p:inputText>
									<h:message id="mnIT" for="nombreIT" />

									<h:outputText value="#{msgs.admCliente_nombreFantasia}" />
									<p:inputText id="nombreFantasiaIT"
										value="#{clienteController.view.nombreFantasia}"
										maxlength="200" size="50">
										<f:validateBean for="nombreFantasiaIT" />
									</p:inputText>
									<h:message id="mnfIT" for="nombreFantasiaIT" />

									<h:outputText value="#{msgs.admCliente_dni}" />
									<p:inputText id="dniIT" value="#{clienteController.view.dni}"
										maxlength="200" size="50">
										<f:validateBean for="dniIT" />
									</p:inputText>
									<h:message id="mdIT" for="dniIT" />

									<h:outputText value="#{msgs.admCliente_cuil}" />
									<p:inputText id="cuilIT" value="#{clienteController.view.cuil}"
										maxlength="200" size="50">
										<f:validateBean for="cuilIT" />
									</p:inputText>
									<h:message id="mclIT" for="cuilIT" />

									<h:outputText value="#{msgs.admCliente_cuit}" />
									<p:inputText id="cuitIT" value="#{clienteController.view.cuit}"
										maxlength="200" size="50">
										<f:validateBean for="cuitIT" />
									</p:inputText>
									<h:message id="mctIT" for="cuitIT" />

								</h:panelGrid>

							</p:panel>
						</p:tab>
						<p:tab id="tabContactos"
							title="#{msgs.admContactos_datosPrincipales}">

							<t:contactoListado
								contactoController="#{clienteController.contactoController}" />

						</p:tab>

						<p:tab title="#{msgs.admDireccion_datosPrincipales}">
							<t:direccion
								direccionController="#{clienteController.direccionController}" />
						</p:tab>

					</p:tabView>



					<!-- ================================================== -->
					<!-- Opciones											-->
					<!-- ================================================== -->
					<h:panelGrid columns="2">
						<p:commandButton value="#{msgs.common_guardar}"
							actionListener="#{clienteController.save}" update=":form">
						</p:commandButton>
						<p:commandButton value="#{msgs.common_volver}"
							actionListener="#{clienteController.cancel}" immediate="true"
							update=":form">
						</p:commandButton>
					</h:panelGrid>
				</h:panelGrid>
			</h:form>

			<t:contacto
				contactoController="#{clienteController.contactoController}"
				onCloseUpdate=":form:tabView:listaContactosDT"
				update=":contactoForm:panelGridContacto, :form:messages, :form:tabView:listaContactosDT" />

		</u:define>
	</u:composition>
</body>
</html>